package com.itheima.advantagesup.mapper;

import com.itheima.advantagesup.dto.SysroleDTO;
import com.itheima.advantagesup.entity.SysMenu;
import com.itheima.advantagesup.entity.Sysrole;
import com.itheima.advantagesup.entity.SysRoleMenu;
import com.itheima.advantagesup.vo.SysroleVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * SysRoleMapper
 *
 * @author liliudong
 * @version 1.0
 * @description
 * @date 2023/7/26 17:51
 */
@Mapper
public interface SysRoleMapper {
    /**
     * 选择名单由ids
     *
     * @param roleIds 角色id
     * @return {@link List}<{@link String}>
     */
    List<String> selectNameListByIds(List<String> roleIds);


    List<Sysrole> findAllrole(String name);

    void addRole(Sysrole sysrole);

    /**
     * 增加角色——菜单
     *
     * @param list
     */
    void addRoleMenu(List<SysRoleMenu> list);

    @Delete("delete from sys_role where id = #{id}")
    void delete(String id);

    @Delete("delete from sys_role_menu where role_id = #{id}")
    void deleteRoleMenu(String id);

    @Select("select * from sys_role where id = #{id}")
    Sysrole getById(String id);

    @Select("select *from sys_role_menu,sys_menu where role_id= #{id} and menu_id=sys_menu.id")
    List<SysMenu> getByIdmenu(String id);

    void update(Sysrole sysrole);

@Select("select * from sys_role")
    List<SysroleDTO> findAll();
}
